home *** CD-ROM | disk | FTP | other *** search
/ Mac Mania 4 / MacMania 4.toast / / Demo's / Igor Demo Pro / 1 PutContentsIn Igor Pro Folder / WaveMetrics Procedures / Data Manipulation / XY Pair To Waveform < prev    next >
Text File  |  1996-01-29  |  2KB  |  53 lines

  1. | Version 1.10, 12/31/95
  2. |    Updated for Igor Pro 3.0
  3.  
  4. #pragma rtGlobals=1
  5.  
  6. | XYToWave1(xWave, yWave, wWaveName, numPoints)
  7. |    Generates a waveform from an XY pair.
  8. |    The name of the output waveform must not be the same as the x or y input wave.
  9. |    The macro makes the assumption that the input waves are already sorted.
  10. |    You can sort with: Sort xWave, xWave, yWave
  11. |    If you have blanks (NaNs) in your input data, this function will give you blanks
  12. |    in your output waveform as well. If you don't want this, you can try the
  13. |    XYToWave2 function below.
  14. Function XYToWave1(xWave, yWave, wWaveName, numPoints)
  15.     Wave xWave                            | x wave in the XY pair
  16.     Wave yWave                            | y wave in the XY pair
  17.     String wWaveName                    | name to use for new waveform wave
  18.     Variable numPoints                    | number of points for waveform
  19.     
  20.     Make/O/N=(numPoints) $wWaveName            | make waveform
  21.     Wave wWave= $wWaveName
  22.     WaveStats/Q xWave                                | find range of x coordinates
  23.     SetScale/I x V_min, V_max, wWave                | set X scaling for waveform
  24.     wWave = interp(x, xWave, yWave)                | do the interpolation
  25. End
  26.  
  27. | XYToWave2(xWave, yWave, wWaveName, numPoints)
  28. |    Generates a waveform from an XY pair.
  29. |    The name of the output waveform must not be the same as the x or y input wave.
  30. |    It must be a simple wave name, not a full or partial path plus wave name.
  31. |    numPoints must be at least as large as the number of points in the XY pair.
  32. |    The input waves need not be sorted.
  33. |    This function interpolates through the NaNs.
  34. Function XYToWave2(xWave, yWave, wWaveName, numPoints)
  35.     Wave xWave                            | x wave in the XY pair
  36.     Wave yWave                            | y wave in the XY pair
  37.     String wWaveName                    | name to use for new waveform wave
  38.     Variable numPoints                    | number of points for waveform
  39.  
  40.     String cmd
  41.     String xWaveName, yWaveName
  42.     String format
  43.     
  44.     wWaveName= PossiblyQuoteName(wWaveName)
  45.     
  46.     xWaveName = GetWavesDataFolder(xWave,4)    | partial path including possibly quoted wave name
  47.     yWaveName = GetWavesDataFolder(yWave,4)
  48.     format = "Interpolate/N=(%d)/E=2/Y=%s %s /X=%s"
  49.     sprintf cmd, format, numPoints, wWaveName, yWaveName, xWaveName
  50.     Execute cmd
  51. End
  52.  
  53.